﻿using System;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;

using JM.JCY.BusinessEntity;
using JM.JCY.Proxy;
using NCS.IConnect.ApplicationContexts;
using JM.JCY.Common;
using JM.JCY.Common.Utilities;
using Microsoft.SharePoint;

namespace JM.JCY.SharePointComponent.IncorruptArchives.CreateSelfControlBusiness
{
    public partial class CreateSelfControlBusinessUserControl : UserControl
    {
        public string _userName
        {
            set { ViewState["_userName"] = value; }
            get { return (string)ViewState["_userName"]; }
        }

        protected void Page_Load(object sender, EventArgs e)
        {
            if (ApplicationContext.Current.UserName != null)
            {
                _userName = ApplicationContext.Current.UserName;
            }

            if (!IsPostBack)
            {
                //this.txtFiller.Text = _userName;
            }
        }

        protected void imgSubmit_Click(object sender, ImageClickEventArgs e)
        {
            using (IncorruptProxy proxy = new IncorruptProxy())
            {
                var newDT = new IncorruptDataSet.T_SelfControl_BusinessDataTable();
                var newRow = newDT.NewT_SelfControl_BusinessRow();

                newRow.Dept = this.txtDept.Text;
                newRow.Filler = this.txtFiller.Text;
                newRow.FillDate = this.dtFillDate.SelectedDate;
                newRow.Position = this.txtPosition.Text;

                newRow.Option_1 = this.rbOption1.SelectedValue;
                newRow.Option_2 = this.rbOption2.SelectedValue;
                newRow.Option_3 = this.rbOption3.SelectedValue;
                newRow.Option_4 = this.rbOption4.SelectedValue;
                newRow.Option_5 = this.rbOption5.SelectedValue;
                newRow.Option_6 = this.rbOption6.SelectedValue;
                newRow.Option_7 = this.rbOption7.SelectedValue;
                newRow.Option_8 = this.rbOption8.SelectedValue;
                newRow.Option_9 = this.rbOption9.SelectedValue;
                newRow.Option_10 = this.rbOption10.SelectedValue;
                newRow.Option_11 = this.rbOption11.SelectedValue;
                newRow.Option_12 = this.rbOption12.SelectedValue;
                newRow.Option_13 = this.rbOption13.SelectedValue;
                newRow.Option_14 = this.rbOption14.SelectedValue;
                newRow.Option_15 = this.rbOption15.SelectedValue;
                newRow.Option_16 = this.rbOption16.SelectedValue;
                newRow.Option_17 = this.rbOption17.SelectedValue;
                newRow.Option_18 = this.rbOption18.SelectedValue;
                newRow.Option_19 = this.rbOption19.SelectedValue;
                newRow.Option_20 = this.rbOption20.SelectedValue;
                newRow.Option_21 = this.rbOption21.SelectedValue;
                newRow.Option_22 = this.rbOption22.SelectedValue;
                newRow.Option_23 = this.rbOption23.SelectedValue;
                newRow.Option_24 = this.rbOption24.SelectedValue;
                newRow.Option_25 = this.rbOption25.SelectedValue;
                newRow.Option_26 = this.rbOption26.SelectedValue;
                newRow.Option_27 = this.rbOption27.SelectedValue;
                newRow.Option_28 = this.rbOption28.SelectedValue;
                newRow.Option_29 = this.rbOption29.SelectedValue;
                newRow.Option_30 = this.rbOption30.SelectedValue;
                newRow.Option_31 = this.rbOption31.SelectedValue;
                newRow.Option_32 = this.rbOption32.SelectedValue;
                newRow.Option_33 = this.rbOption33.SelectedValue;
                newRow.Option_34 = this.rbOption34.SelectedValue;
                newRow.Option_35 = this.rbOption35.SelectedValue;

                newRow.Remark_1 = this.txtRemark1.Text;
                newRow.Remark_2 = this.txtRemark2.Text;
                newRow.Remark_3 = this.txtRemark3.Text;
                newRow.Remark_4 = this.txtRemark4.Text;
                newRow.Remark_5 = this.txtRemark5.Text;
                newRow.Remark_6 = this.txtRemark6.Text;
                newRow.Remark_7 = this.txtRemark7.Text;
                newRow.Remark_8 = this.txtRemark8.Text;
                newRow.Remark_9 = this.txtRemark9.Text;
                newRow.Remark_10 = this.txtRemark10.Text;
                newRow.Remark_11 = this.txtRemark11.Text;
                newRow.Remark_12 = this.txtRemark12.Text;
                newRow.Remark_13 = this.txtRemark13.Text;
                newRow.Remark_14 = this.txtRemark14.Text;
                newRow.Remark_15 = this.txtRemark15.Text;
                newRow.Remark_16 = this.txtRemark16.Text;
                newRow.Remark_17 = this.txtRemark17.Text;
                newRow.Remark_18 = this.txtRemark18.Text;
                newRow.Remark_19 = this.txtRemark19.Text;
                newRow.Remark_20 = this.txtRemark20.Text;
                newRow.Remark_21 = this.txtRemark21.Text;
                newRow.Remark_22 = this.txtRemark22.Text;
                newRow.Remark_23 = this.txtRemark23.Text;
                newRow.Remark_24 = this.txtRemark24.Text;
                newRow.Remark_25 = this.txtRemark25.Text;
                newRow.Remark_26 = this.txtRemark26.Text;
                newRow.Remark_27 = this.txtRemark27.Text;
                newRow.Remark_28 = this.txtRemark28.Text;
                newRow.Remark_29 = this.txtRemark29.Text;
                newRow.Remark_30 = this.txtRemark30.Text;
                newRow.Remark_31 = this.txtRemark31.Text;
                newRow.Remark_32 = this.txtRemark32.Text;
                newRow.Remark_33 = this.txtRemark33.Text;
                newRow.Remark_34 = this.txtRemark34.Text;
                newRow.Remark_35 = this.txtRemark35.Text;

                JCYUtility.UpdateCommonFields(newRow, "Iori");
                newDT.AddT_SelfControl_BusinessRow(newRow);
                proxy.UpdateSelfControlBusiness(newDT);

                Response.Redirect("SelfControlBusiness.aspx");
            }

        }

        protected void imgCancel_Click(object sender, ImageClickEventArgs e)
        {
            Response.Redirect("SelfControlBusiness.aspx");
        }
    }
}
